Imports Microsoft.VisualBasic.CompilerServices
Imports System
Imports System.Web.UI
Imports System.Web.UI.HtmlControls

Public Class BasePage
    Inherits Page

    Public Sub New()
        AddHandler MyBase.Load, AddressOf Page_Load
    End Sub

    Private Sub Page_Load(sender As Object, e As EventArgs)
        Dim htmlGenericControl As HtmlGenericControl
        htmlGenericControl = New HtmlGenericControl("script")
        htmlGenericControl.Attributes.Add("type", "text/javascript")
        htmlGenericControl.Attributes.Add("src", Me.Page.ClientScript.GetWebResourceUrl(GetType(BasePage), "StartFrame.Web.StartFrame.Scripts.js"))
        Me.Page.Header.Controls.AddAt(0, htmlGenericControl)
        htmlGenericControl = New HtmlGenericControl("script")
        htmlGenericControl.Attributes.Add("type", "text/javascript")
        htmlGenericControl.Attributes.Add("src", Me.Page.ClientScript.GetWebResourceUrl(GetType(BasePage), "StartFrame.Web.Exporter.js"))
        Me.Page.Header.Controls.AddAt(0, htmlGenericControl)
        htmlGenericControl = New HtmlGenericControl("script")
        htmlGenericControl.Attributes.Add("type", "text/javascript")
        htmlGenericControl.Attributes.Add("src", Me.Page.ClientScript.GetWebResourceUrl(GetType(BasePage), "StartFrame.Web.ABMBase.js"))
        Me.Page.Header.Controls.AddAt(0, htmlGenericControl)
        htmlGenericControl = New HtmlGenericControl("script")
        htmlGenericControl.Attributes.Add("type", "text/javascript")
        htmlGenericControl.Attributes.Add("src", Me.Page.ClientScript.GetWebResourceUrl(GetType(BasePage), "StartFrame.Web.FormBase.js"))
        Me.Page.Header.Controls.AddAt(0, htmlGenericControl)
        htmlGenericControl = New HtmlGenericControl("script")
        htmlGenericControl.Attributes.Add("type", "text/javascript")
        htmlGenericControl.Attributes.Add("src", Me.Page.ClientScript.GetWebResourceUrl(GetType(BasePage), "StartFrame.Web.FiltersFeature.js"))
        Me.Page.Header.Controls.AddAt(0, htmlGenericControl)
        htmlGenericControl = New HtmlGenericControl("script")
        htmlGenericControl.Attributes.Add("type", "text/javascript")
        htmlGenericControl.Attributes.Add("src", Me.Page.ClientScript.GetWebResourceUrl(GetType(BasePage), "StartFrame.Web.ext-lang-es.js"))
        Me.Page.Header.Controls.AddAt(0, htmlGenericControl)
        htmlGenericControl = New HtmlGenericControl("script")
        htmlGenericControl.Attributes.Add("type", "text/javascript")
        htmlGenericControl.Attributes.Add("src", Me.Page.ClientScript.GetWebResourceUrl(GetType(BasePage), "StartFrame.Web.ext-all.js"))
        Me.Page.Header.Controls.AddAt(0, htmlGenericControl)

        htmlGenericControl = New HtmlGenericControl("link")
        htmlGenericControl.Attributes.Add("rel", "stylesheet")
        htmlGenericControl.Attributes.Add("type", "text/css")
        htmlGenericControl.Attributes.Add("href", ResolveUrl("~/resources/css/images.css"))
        Me.Page.Header.Controls.AddAt(0, htmlGenericControl)

        htmlGenericControl = New HtmlGenericControl("link")
        htmlGenericControl.Attributes.Add("rel", "stylesheet")
        htmlGenericControl.Attributes.Add("type", "text/css")
        htmlGenericControl.Attributes.Add("href", ResolveUrl("~/resources/css/RangeMenu.css"))
        Me.Page.Header.Controls.AddAt(0, htmlGenericControl)

        htmlGenericControl = New HtmlGenericControl("link")
        htmlGenericControl.Attributes.Add("rel", "stylesheet")
        htmlGenericControl.Attributes.Add("type", "text/css")
        htmlGenericControl.Attributes.Add("href", ResolveUrl("~/resources/css/GridFilters.css"))
        Me.Page.Header.Controls.AddAt(0, htmlGenericControl)

        htmlGenericControl = New HtmlGenericControl("link")
        htmlGenericControl.Attributes.Add("rel", "stylesheet")
        htmlGenericControl.Attributes.Add("type", "text/css")
        htmlGenericControl.Attributes.Add("href", ResolveUrl("~/resources/css/ext-all.css"))
        Me.Page.Header.Controls.AddAt(0, htmlGenericControl)

        Try
            Dim iHTML As String = ""
            If Common.Env.GetConfigValue("useIdentity") = True Then
                iHTML = String.Format("var useIdentity = true; Ext.onReady(function () {{serverLogin('{0}', null);}});", System.Web.HttpUtility.JavaScriptStringEncode(System.Web.HttpContext.Current.User.Identity.Name))
                htmlGenericControl = New HtmlGenericControl("script")
                htmlGenericControl.Attributes.Add("type", "text/javascript")
                htmlGenericControl.InnerHtml = iHTML
                Me.Page.Header.Controls.Add(htmlGenericControl)
            End If
        Catch

        End Try


    End Sub
End Class
